﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Routing;
using MyBlog.Common;
using SubwayHelper;

namespace MyBlog.Web.Controllers
{
    public class SubwayController : ApiController
    {
        // GET api/subway
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        /// <summary>
        /// 地铁换乘查询
        /// </summary>
        /// <param name="dep">始发站</param>
        /// <param name="dest">到达站</param>
        /// <param name="city">所在城市</param>
        /// <returns></returns>
        [ActionName("q")]
        public List<QueryResult> GetTransQuery(string dep, string dest, CityEnum city)
        {
            try
            {
                var result = Subway.GetRideSubwayInfo(dep, dest, city).OrderBy(x => x.Range).ToList();
                return result;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.Message);
                return null;
            }
        }

        // GET api/subway/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/subway
        public void Post([FromBody]string value)
        {
        }

        // PUT api/subway/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/subway/5
        public void Delete(int id)
        {
        }
    }
}
